from datetime import date
from random import  randint
def brithday_people(list_name):
    dic = {}.fromkeys(list_name)
    for key in dic:
        year = randint(1990,2020)
        month = randint(1,12)
        day = randint(1,31)
        dic[key] = date(year,month,day)
    return dic
def summer_people(dic):
    people_list = []
    for key in dic:
        if dic[key].month >= 6 and dic[key].month <=8:
            people_list.append(key)
    return people_list
def Age(dic):
    age_list = list(dic)
    age_list.sort()
    old = age_list[-1]
    young = age_list[0]
    print('年龄最大的是 : {val}'.\
          format(val = old))
    print('年龄最小的是 : {val}'.\
          format(val = young))
def day(dic):
    day_list = list(dic.values())
    day_list.sort()
    Old = day_list[-1]
    Young = day_list[0]
    days = (Old - Young).days
    return days
def max_birthday(dic:dict):
    mlist = list(dic.values())
    for i in range(len(mlist)):
        mlist[i] = mlist[i].replace(year = 1990)
    mlist.sort()
    max = mlist[-1]
    for key in dic:
        if max.month == dic[key].month and max.day == dic[key].day:
            return key
def min_birthday(dic:dict):
    nlist = list(dic.values())
    for i in range(len(nlist)):
        nlist[i] = nlist[i].replace(year = 1990)
    nlist.sort()
    min = nlist[0]
    for key in dic:
        if min.month == dic[key].month and min.day == dic[key].day:
            return key
if __name__ == '__main__':
    name_list = ['张三','李四','王五','溜溜','琪琪','娟娟','香茗','小明','小红','小强']
    date = brithday_people(name_list)
    print('随机生成十个人的生日：{val}'.\
          format(val = date))
    print('夏季6月-8月出生的是：{val}'.\
          format(val = summer_people(date)))
    Age(date)
    print('最大的比最小的大{val}天'.\
          format(val = day(date)))
    print('生日最大的人是：{val}'.\
          format(val = max_birthday(date)))
    print('生日最小的人是：{val}'. \
          format(val=min_birthday(date)))


